package com.example.chapter.util;

import android.content.Context;

/**
 * Author:LiuZejiang
 * Date:2022/10/3  16:37
 * JDK-Version:1.8
 */
public class Utils {

    //根据手机的分辨率从dp的单位转成px
    public static int dip2px(Context context,float dpValue) {

        float scale = context.getResources().getDisplayMetrics().density;//获取当前手机的像素密度 1dp=?px
        return (int)(dpValue*scale + 0.5f); //四舍五入取整
    }
}
